package map;
import java.util.*;

/**
 * @Classname TestMap
 * @Description TODO
 * @Date 2021/5/16 15:06
 * @Created by 张斌
 */
public class TestMap {
    public static void main(String[] args) {
        tesetHashMap2();
    }
    public static void tesetHashMap2() {
        HashMap<String,String> hashMap=new HashMap<String, String> ();
        hashMap.put("zangsan","lisi");
        Set<Map.Entry < String, String>> set= hashMap.entrySet();
        System.out.println(set.size());
        for (Map.Entry<String, String> entry : set){
            System.out.println(entry.getKey()+":"+entry.getValue());
        }
       Iterator iterator= hashMap.entrySet().iterator();
        while(iterator.hasNext()){
            Map.Entry<String,String> element= (Map.Entry<String, String>) iterator.next();
            System.out.println(element.getKey() +":"+element.getValue());
        }

        System.out.println(set.toArray()[0]);
    }

    public static void testSet() {
        HashSet<String> hashSet=new HashSet<String> ();
        hashSet.add("zhangdsn");
        hashSet.add("lisit");
        System.out.println(hashSet);
    }
}
